{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>结果列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
                <div  class="col-sm-2" style="width: 100px">
                    <div class="input-group" >  
                        <a href="{:url('optionResultAdd')}"><button class="btn btn-outline btn-primary" type="button">添加结果</button></a>
                    </div>
                </div>

                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('index')}">
                        <div class="col-sm-2">

                                <input type="text" id="key" class="form-control" name="key" value="{$val}" placeholder="输入需查询的名称" />

                        </div>


<!--                        <div class="col-sm-2">-->

<!--                                <select class="form-control m-b chosen-select" name="cat_id" id='cat_id'>-->
<!--                                    <option value="0">选择题目分类</option>-->
<!--                                    {volist name="question_cat" id="vo"}-->
<!--                                    <option value="{$vo.id}" {if condition="$cat_id eq $vo.id"}selected{/if}>{$vo.name}</option>-->
<!--                                    {/volist}-->
<!--                                </select>-->

<!--                        </div>-->


                        <div class="col-sm-2">

                            <select class="form-control m-b chosen-select" name="question_id" id='question_id'>
                                <option value="0">选择题目</option>
                                {volist name="question" id="vo"}
                                <option value="{$vo.id}" {if condition="$question_id eq $vo.id"}selected{/if}>{$vo.name}</option>
                                {/volist}
                            </select>

                        </div>

                        <span class="input-group-btn">
                                 <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                         </span>
                    </form>

                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>
              <input type="hidden" value="{$page}" id="pp">
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover" id="tt">
                        <thead>
                            <tr class="long-tr">
                                <th><input type="checkbox" class="checkall" /></th>
                                <th>ID</th>

                                <th>关联题目</th>
                                <th>名称</th>

                                <th>类型</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <script id="list-template" type="text/html">
                            {{# for(var i=0;i<d.length;i++){  }}

                            <tr class="long-td">
                                <td><input type="checkbox"  class="checkchild" name="checkchild[]" value="{{d[i].id}}"></td>
                                <td>{{d[i].id}}</td>

                                <td>{{d[i].q_name}}</td>
                                <td>{{d[i].name}}</td>

                                <td>
                                    {{# if(d[i].type==1){ }}
                                    <a class="red" href="javascript:;" >
                                        <div id="zt{{d[i].id}}"><span class="label label-info">匹配标识</span></div>
                                    </a>
                                    {{# }else if(d[i].type==2){ }}
                                    <a class="red" href="javascript:;" >
                                        <div id="zt{{d[i].id}}"><span class="label label-success">分值区间</span></div>
                                    </a>
                                    {{# } }}
                                </td>
                                <td>{{d[i].create_time}}</td>
                                <td>
<!--                                    <a href="javascript:;" onclick="ShowTlp({{d[i].id}})" class="btn btn-success btn-outline btn-xs">-->
<!--                                        <i class="fa fa-tag"></i> 关联模板</a>&nbsp;&nbsp;-->
                                    <a href="javascript:;" onclick="QuestionEdit({{d[i].id}})" class="btn btn-primary btn-outline btn-xs">
                                        <i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp;
                                    <a href="javascript:;" onclick="QuestionDel({{d[i].id}})" class="btn btn-danger btn-outline btn-xs">
                                        <i class="fa fa-trash-o"></i> 删除</a>
                                </td>
                            </tr>
                            {{# } }}
                        </script>
                        <tbody id="list-content"></tbody>
                    </table>
                    <div id="AjaxPage" style=" text-align: right;"></div>
                    <div id="allpage" style=" text-align: right;"></div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

<!-- 加载动画 -->
<div class="spiner-example">
    <div class="sk-spinner sk-spinner-three-bounce">
        <div class="sk-bounce1"></div>
        <div class="sk-bounce2"></div>
        <div class="sk-bounce3"></div>
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">
   
    //laypage分页
    Ajaxpage();
    function Ajaxpage(curr){
        var key=$('#key').val();
        var cat_id=$('#cat_id').val();
        var question_id=$('#question_id').val();
        if(curr && curr >= 1){
            $('#pp').val(curr);
        }else{
            curr =  $('#pp').val();
        }
        $.getJSON('{:url("optionResult/index")}', {page: curr || 1,key:key,cat_id:cat_id,question_id:question_id}, function(data){
            $(".spiner-example").css('display','none'); //数据加载完关闭动画 
            if(data==''){
                $("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
            }else{
                var tpl = document.getElementById('list-template').innerHTML;
                laytpl(tpl).render(data, function(html){
                    document.getElementById('list-content').innerHTML = html;
                });
                laypage({
                    cont: $('#AjaxPage'),//容器。值支持id名、原生dom对象，jquery对象,
                    pages:'{$allpage}',//总页数
                    skip: true,//是否开启跳页
                    skin: '#1AB5B7',//分页组件颜色
                    curr: curr || 1,
                    groups: 3,//连续显示分页数
                    jump: function(obj, first){
                        if(!first){
                            Ajaxpage(obj.curr)
                        }
                        $('#allpage').html('第'+ obj.curr +'页，共'+ obj.pages +'页');
                    }
                });
            }
        });
    }

    //批量
    /*$("#tt").on('click','.checkall',function () {
        var check = $(this).prop("checked");
        $(".checkchild").prop("checked", check);
        var checks = document.getElementsByName("checkchild[]");
        console.log(checks,check);
        if(checks.length>0)
        {
            for(i=0;i<checks.length;i++){
                checks[i].checked = check;
                var a = $(".checkchildspan").eq(i);
                /!*if(a.attr('status') != -1)
                {
                    checks[i].checked = false;
                }*!/
            }
        }
    });*/




//编辑轮播
function QuestionEdit(id){
    location.href = './optionResultEdit/id/'+id+'&page='+$('#pp').val();
}





    function ShowTlp(id){
        location.href = '/admin/result/index/id/'+id+'.html';
    }


//删除轮播
function QuestionDel(id){
    lunhui.confirm(id,'{:url("optionResultDel")}');
}


//状态
function question_show_state(id){

    $.post('{:url("optionResult_show_state")}',{id:id},function(data){
        if(data.code==1){
            var a='<span class="label label-danger">下架</span>'
            $('#zt1'+id).html(a);
            layer.msg(data.msg,{icon:2,time:1500,shade: 0.1,});
            return false;
        }else{
            var b='<span class="label label-info">上架</span>'
            $('#zt1'+id).html(b);
            layer.msg(data.msg,{icon:1,time:1500,shade: 0.1,});
            return false;
        }
    });
    return false;

}




</script>
</body>
</html>